// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

import test from 'ava';

import { Decimal, Locale, DecimalFormatter, DecimalGroupingStrategy, DataProvider } from 'icu';

test('use createFromBlob to format a simple decimal', async t => {
  // icu4x-datagen --markers DecimalSymbolsV1 DecimalDigitsV1 --locales bn --format blob --out bn.blob && xxd -i bn.blob
  const bnBlob = [
    0x03, 0x08, 0x31, 0x43, 0x45, 0x84, 0x99, 0x47, 0xd1, 0xf9, 0xd3, 0x01,
    0x02, 0x00, 0x20, 0x00, 0xc2, 0x62, 0x75, 0x18, 0x6e, 0x90, 0x0b, 0xc2,
    0x1e, 0x2d, 0x06, 0x6c, 0x61, 0x74, 0x6e, 0x90, 0x0c, 0x49, 0x4e, 0x90,
    0x0b, 0x1e, 0x6c, 0x61, 0x74, 0x6e, 0x90, 0x0c, 0x6e, 0x64, 0x90, 0x0d,
    0x75, 0x6e, 0x64, 0x1e, 0xce, 0x61, 0x62, 0x63, 0x64, 0x67, 0x68, 0x6a,
    0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x74, 0x76, 0x0f, 0x13, 0x18, 0x1c, 0x25,
    0x34, 0x39, 0x44, 0x4d, 0x64, 0x68, 0x73, 0x8a, 0xc2, 0x64, 0x72, 0x04,
    0x6c, 0x6d, 0x90, 0x0a, 0x61, 0x62, 0x81, 0x65, 0x78, 0x74, 0x82, 0x65,
    0x6e, 0x67, 0x85, 0x61, 0x6b, 0x6d, 0x90, 0x08, 0x65, 0x76, 0x61, 0x84,
    0x75, 0xc2, 0x6a, 0x72, 0x02, 0x72, 0x87, 0x75, 0x86, 0xc2, 0x61, 0x6d,
    0x07, 0x6e, 0x69, 0x64, 0x65, 0x63, 0x90, 0x04, 0x6e, 0x70, 0x90, 0x09,
    0x61, 0x76, 0x61, 0x90, 0x06, 0xc2, 0x68, 0x6e, 0x04, 0x6d, 0x72, 0x90,
    0x01, 0x64, 0x61, 0x8b, 0x61, 0xc2, 0x6f, 0x74, 0x02, 0x6f, 0x8e, 0x6e,
    0x80, 0xc4, 0x6c, 0x6f, 0x74, 0x79, 0x03, 0x07, 0x0b, 0x79, 0x6d, 0x8c,
    0x6e, 0x67, 0x90, 0x02, 0x65, 0x69, 0x90, 0x07, 0x6d, 0x72, 0x90, 0x00,
    0x6b, 0x6f, 0x6f, 0x83, 0xc2, 0x6c, 0x72, 0x04, 0x63, 0x6b, 0x90, 0x03,
    0x79, 0x61, 0x88, 0xc4, 0x61, 0x65, 0x68, 0x69, 0x06, 0x09, 0x0c, 0x6d,
    0x6c, 0x64, 0x65, 0x63, 0x89, 0x6c, 0x75, 0x8a, 0x61, 0x69, 0x8d, 0x62,
    0x74, 0x8f, 0x61, 0x69, 0x69, 0x90, 0x05, 0xd2, 0x09, 0x1e, 0x00, 0x00,
    0x00, 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00,
    0x00, 0x6e, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00,
    0x00, 0xe6, 0x00, 0x00, 0x00, 0x0e, 0x01, 0x00, 0x00, 0x36, 0x01, 0x00,
    0x00, 0x5e, 0x01, 0x00, 0x00, 0x86, 0x01, 0x00, 0x00, 0xae, 0x01, 0x00,
    0x00, 0xd6, 0x01, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x26, 0x02, 0x00,
    0x00, 0x4e, 0x02, 0x00, 0x00, 0x76, 0x02, 0x00, 0x00, 0x9e, 0x02, 0x00,
    0x00, 0xc6, 0x02, 0x00, 0x00, 0xee, 0x02, 0x00, 0x00, 0x16, 0x03, 0x00,
    0x00, 0x3e, 0x03, 0x00, 0x00, 0x66, 0x03, 0x00, 0x00, 0x8e, 0x03, 0x00,
    0x00, 0xc0, 0x03, 0x00, 0x00, 0xf2, 0x03, 0x00, 0x00, 0x24, 0x04, 0x00,
    0x00, 0x36, 0x04, 0x00, 0x00, 0x48, 0x04, 0x00, 0x00, 0x01, 0x30, 0x01,
    0x31, 0x01, 0x32, 0x01, 0x33, 0x01, 0x34, 0x01, 0x35, 0x01, 0x36, 0x01,
    0x37, 0x01, 0x38, 0x01, 0x39, 0x02, 0xd9, 0xa0, 0x02, 0xd9, 0xa1, 0x02,
    0xd9, 0xa2, 0x02, 0xd9, 0xa3, 0x02, 0xd9, 0xa4, 0x02, 0xd9, 0xa5, 0x02,
    0xd9, 0xa6, 0x02, 0xd9, 0xa7, 0x02, 0xd9, 0xa8, 0x02, 0xd9, 0xa9, 0x02,
    0xdb, 0xb0, 0x02, 0xdb, 0xb1, 0x02, 0xdb, 0xb2, 0x02, 0xdb, 0xb3, 0x02,
    0xdb, 0xb4, 0x02, 0xdb, 0xb5, 0x02, 0xdb, 0xb6, 0x02, 0xdb, 0xb7, 0x02,
    0xdb, 0xb8, 0x02, 0xdb, 0xb9, 0x02, 0xdf, 0x80, 0x02, 0xdf, 0x81, 0x02,
    0xdf, 0x82, 0x02, 0xdf, 0x83, 0x02, 0xdf, 0x84, 0x02, 0xdf, 0x85, 0x02,
    0xdf, 0x86, 0x02, 0xdf, 0x87, 0x02, 0xdf, 0x88, 0x02, 0xdf, 0x89, 0x03,
    0xe0, 0xa5, 0xa6, 0x03, 0xe0, 0xa5, 0xa7, 0x03, 0xe0, 0xa5, 0xa8, 0x03,
    0xe0, 0xa5, 0xa9, 0x03, 0xe0, 0xa5, 0xaa, 0x03, 0xe0, 0xa5, 0xab, 0x03,
    0xe0, 0xa5, 0xac, 0x03, 0xe0, 0xa5, 0xad, 0x03, 0xe0, 0xa5, 0xae, 0x03,
    0xe0, 0xa5, 0xaf, 0x03, 0xe0, 0xa7, 0xa6, 0x03, 0xe0, 0xa7, 0xa7, 0x03,
    0xe0, 0xa7, 0xa8, 0x03, 0xe0, 0xa7, 0xa9, 0x03, 0xe0, 0xa7, 0xaa, 0x03,
    0xe0, 0xa7, 0xab, 0x03, 0xe0, 0xa7, 0xac, 0x03, 0xe0, 0xa7, 0xad, 0x03,
    0xe0, 0xa7, 0xae, 0x03, 0xe0, 0xa7, 0xaf, 0x03, 0xe0, 0xa9, 0xa6, 0x03,
    0xe0, 0xa9, 0xa7, 0x03, 0xe0, 0xa9, 0xa8, 0x03, 0xe0, 0xa9, 0xa9, 0x03,
    0xe0, 0xa9, 0xaa, 0x03, 0xe0, 0xa9, 0xab, 0x03, 0xe0, 0xa9, 0xac, 0x03,
    0xe0, 0xa9, 0xad, 0x03, 0xe0, 0xa9, 0xae, 0x03, 0xe0, 0xa9, 0xaf, 0x03,
    0xe0, 0xab, 0xa6, 0x03, 0xe0, 0xab, 0xa7, 0x03, 0xe0, 0xab, 0xa8, 0x03,
    0xe0, 0xab, 0xa9, 0x03, 0xe0, 0xab, 0xaa, 0x03, 0xe0, 0xab, 0xab, 0x03,
    0xe0, 0xab, 0xac, 0x03, 0xe0, 0xab, 0xad, 0x03, 0xe0, 0xab, 0xae, 0x03,
    0xe0, 0xab, 0xaf, 0x03, 0xe0, 0xad, 0xa6, 0x03, 0xe0, 0xad, 0xa7, 0x03,
    0xe0, 0xad, 0xa8, 0x03, 0xe0, 0xad, 0xa9, 0x03, 0xe0, 0xad, 0xaa, 0x03,
    0xe0, 0xad, 0xab, 0x03, 0xe0, 0xad, 0xac, 0x03, 0xe0, 0xad, 0xad, 0x03,
    0xe0, 0xad, 0xae, 0x03, 0xe0, 0xad, 0xaf, 0x03, 0xe0, 0xaf, 0xa6, 0x03,
    0xe0, 0xaf, 0xa7, 0x03, 0xe0, 0xaf, 0xa8, 0x03, 0xe0, 0xaf, 0xa9, 0x03,
    0xe0, 0xaf, 0xaa, 0x03, 0xe0, 0xaf, 0xab, 0x03, 0xe0, 0xaf, 0xac, 0x03,
    0xe0, 0xaf, 0xad, 0x03, 0xe0, 0xaf, 0xae, 0x03, 0xe0, 0xaf, 0xaf, 0x03,
    0xe0, 0xb1, 0xa6, 0x03, 0xe0, 0xb1, 0xa7, 0x03, 0xe0, 0xb1, 0xa8, 0x03,
    0xe0, 0xb1, 0xa9, 0x03, 0xe0, 0xb1, 0xaa, 0x03, 0xe0, 0xb1, 0xab, 0x03,
    0xe0, 0xb1, 0xac, 0x03, 0xe0, 0xb1, 0xad, 0x03, 0xe0, 0xb1, 0xae, 0x03,
    0xe0, 0xb1, 0xaf, 0x03, 0xe0, 0xb3, 0xa6, 0x03, 0xe0, 0xb3, 0xa7, 0x03,
    0xe0, 0xb3, 0xa8, 0x03, 0xe0, 0xb3, 0xa9, 0x03, 0xe0, 0xb3, 0xaa, 0x03,
    0xe0, 0xb3, 0xab, 0x03, 0xe0, 0xb3, 0xac, 0x03, 0xe0, 0xb3, 0xad, 0x03,
    0xe0, 0xb3, 0xae, 0x03, 0xe0, 0xb3, 0xaf, 0x03, 0xe0, 0xb5, 0xa6, 0x03,
    0xe0, 0xb5, 0xa7, 0x03, 0xe0, 0xb5, 0xa8, 0x03, 0xe0, 0xb5, 0xa9, 0x03,
    0xe0, 0xb5, 0xaa, 0x03, 0xe0, 0xb5, 0xab, 0x03, 0xe0, 0xb5, 0xac, 0x03,
    0xe0, 0xb5, 0xad, 0x03, 0xe0, 0xb5, 0xae, 0x03, 0xe0, 0xb5, 0xaf, 0x03,
    0xe0, 0xb9, 0x90, 0x03, 0xe0, 0xb9, 0x91, 0x03, 0xe0, 0xb9, 0x92, 0x03,
    0xe0, 0xb9, 0x93, 0x03, 0xe0, 0xb9, 0x94, 0x03, 0xe0, 0xb9, 0x95, 0x03,
    0xe0, 0xb9, 0x96, 0x03, 0xe0, 0xb9, 0x97, 0x03, 0xe0, 0xb9, 0x98, 0x03,
    0xe0, 0xb9, 0x99, 0x03, 0xe0, 0xbb, 0x90, 0x03, 0xe0, 0xbb, 0x91, 0x03,
    0xe0, 0xbb, 0x92, 0x03, 0xe0, 0xbb, 0x93, 0x03, 0xe0, 0xbb, 0x94, 0x03,
    0xe0, 0xbb, 0x95, 0x03, 0xe0, 0xbb, 0x96, 0x03, 0xe0, 0xbb, 0x97, 0x03,
    0xe0, 0xbb, 0x98, 0x03, 0xe0, 0xbb, 0x99, 0x03, 0xe0, 0xbc, 0xa0, 0x03,
    0xe0, 0xbc, 0xa1, 0x03, 0xe0, 0xbc, 0xa2, 0x03, 0xe0, 0xbc, 0xa3, 0x03,
    0xe0, 0xbc, 0xa4, 0x03, 0xe0, 0xbc, 0xa5, 0x03, 0xe0, 0xbc, 0xa6, 0x03,
    0xe0, 0xbc, 0xa7, 0x03, 0xe0, 0xbc, 0xa8, 0x03, 0xe0, 0xbc, 0xa9, 0x03,
    0xe1, 0x81, 0x80, 0x03, 0xe1, 0x81, 0x81, 0x03, 0xe1, 0x81, 0x82, 0x03,
    0xe1, 0x81, 0x83, 0x03, 0xe1, 0x81, 0x84, 0x03, 0xe1, 0x81, 0x85, 0x03,
    0xe1, 0x81, 0x86, 0x03, 0xe1, 0x81, 0x87, 0x03, 0xe1, 0x81, 0x88, 0x03,
    0xe1, 0x81, 0x89, 0x03, 0xe1, 0x9f, 0xa0, 0x03, 0xe1, 0x9f, 0xa1, 0x03,
    0xe1, 0x9f, 0xa2, 0x03, 0xe1, 0x9f, 0xa3, 0x03, 0xe1, 0x9f, 0xa4, 0x03,
    0xe1, 0x9f, 0xa5, 0x03, 0xe1, 0x9f, 0xa6, 0x03, 0xe1, 0x9f, 0xa7, 0x03,
    0xe1, 0x9f, 0xa8, 0x03, 0xe1, 0x9f, 0xa9, 0x03, 0xe1, 0xa0, 0x90, 0x03,
    0xe1, 0xa0, 0x91, 0x03, 0xe1, 0xa0, 0x92, 0x03, 0xe1, 0xa0, 0x93, 0x03,
    0xe1, 0xa0, 0x94, 0x03, 0xe1, 0xa0, 0x95, 0x03, 0xe1, 0xa0, 0x96, 0x03,
    0xe1, 0xa0, 0x97, 0x03, 0xe1, 0xa0, 0x98, 0x03, 0xe1, 0xa0, 0x99, 0x03,
    0xe1, 0xb1, 0x90, 0x03, 0xe1, 0xb1, 0x91, 0x03, 0xe1, 0xb1, 0x92, 0x03,
    0xe1, 0xb1, 0x93, 0x03, 0xe1, 0xb1, 0x94, 0x03, 0xe1, 0xb1, 0x95, 0x03,
    0xe1, 0xb1, 0x96, 0x03, 0xe1, 0xb1, 0x97, 0x03, 0xe1, 0xb1, 0x98, 0x03,
    0xe1, 0xb1, 0x99, 0x03, 0xe3, 0x80, 0x87, 0x03, 0xe4, 0xb8, 0x80, 0x03,
    0xe4, 0xba, 0x8c, 0x03, 0xe4, 0xb8, 0x89, 0x03, 0xe5, 0x9b, 0x9b, 0x03,
    0xe4, 0xba, 0x94, 0x03, 0xe5, 0x85, 0xad, 0x03, 0xe4, 0xb8, 0x83, 0x03,
    0xe5, 0x85, 0xab, 0x03, 0xe4, 0xb9, 0x9d, 0x03, 0xea, 0x98, 0xa0, 0x03,
    0xea, 0x98, 0xa1, 0x03, 0xea, 0x98, 0xa2, 0x03, 0xea, 0x98, 0xa3, 0x03,
    0xea, 0x98, 0xa4, 0x03, 0xea, 0x98, 0xa5, 0x03, 0xea, 0x98, 0xa6, 0x03,
    0xea, 0x98, 0xa7, 0x03, 0xea, 0x98, 0xa8, 0x03, 0xea, 0x98, 0xa9, 0x03,
    0xea, 0xa7, 0x90, 0x03, 0xea, 0xa7, 0x91, 0x03, 0xea, 0xa7, 0x92, 0x03,
    0xea, 0xa7, 0x93, 0x03, 0xea, 0xa7, 0x94, 0x03, 0xea, 0xa7, 0x95, 0x03,
    0xea, 0xa7, 0x96, 0x03, 0xea, 0xa7, 0x97, 0x03, 0xea, 0xa7, 0x98, 0x03,
    0xea, 0xa7, 0x99, 0x03, 0xea, 0xaf, 0xb0, 0x03, 0xea, 0xaf, 0xb1, 0x03,
    0xea, 0xaf, 0xb2, 0x03, 0xea, 0xaf, 0xb3, 0x03, 0xea, 0xaf, 0xb4, 0x03,
    0xea, 0xaf, 0xb5, 0x03, 0xea, 0xaf, 0xb6, 0x03, 0xea, 0xaf, 0xb7, 0x03,
    0xea, 0xaf, 0xb8, 0x03, 0xea, 0xaf, 0xb9, 0x04, 0xf0, 0x91, 0x84, 0xb6,
    0x04, 0xf0, 0x91, 0x84, 0xb7, 0x04, 0xf0, 0x91, 0x84, 0xb8, 0x04, 0xf0,
    0x91, 0x84, 0xb9, 0x04, 0xf0, 0x91, 0x84, 0xba, 0x04, 0xf0, 0x91, 0x84,
    0xbb, 0x04, 0xf0, 0x91, 0x84, 0xbc, 0x04, 0xf0, 0x91, 0x84, 0xbd, 0x04,
    0xf0, 0x91, 0x84, 0xbe, 0x04, 0xf0, 0x91, 0x84, 0xbf, 0x04, 0xf0, 0x9e,
    0x85, 0x80, 0x04, 0xf0, 0x9e, 0x85, 0x81, 0x04, 0xf0, 0x9e, 0x85, 0x82,
    0x04, 0xf0, 0x9e, 0x85, 0x83, 0x04, 0xf0, 0x9e, 0x85, 0x84, 0x04, 0xf0,
    0x9e, 0x85, 0x85, 0x04, 0xf0, 0x9e, 0x85, 0x86, 0x04, 0xf0, 0x9e, 0x85,
    0x87, 0x04, 0xf0, 0x9e, 0x85, 0x88, 0x04, 0xf0, 0x9e, 0x85, 0x89, 0x04,
    0xf0, 0x9e, 0xa5, 0x90, 0x04, 0xf0, 0x9e, 0xa5, 0x91, 0x04, 0xf0, 0x9e,
    0xa5, 0x92, 0x04, 0xf0, 0x9e, 0xa5, 0x93, 0x04, 0xf0, 0x9e, 0xa5, 0x94,
    0x04, 0xf0, 0x9e, 0xa5, 0x95, 0x04, 0xf0, 0x9e, 0xa5, 0x96, 0x04, 0xf0,
    0x9e, 0xa5, 0x97, 0x04, 0xf0, 0x9e, 0xa5, 0x98, 0x04, 0xf0, 0x9e, 0xa5,
    0x99, 0x0e, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x2d, 0x2b, 0x2e, 0x2c,
    0x62, 0x65, 0x6e, 0x67, 0x03, 0x02, 0x01, 0x0e, 0x01, 0x01, 0x02, 0x02,
    0x03, 0x04, 0x2d, 0x2b, 0x2e, 0x2c, 0x6c, 0x61, 0x74, 0x6e, 0x03, 0x02,
    0x01, 0x0e, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x2d, 0x2b, 0x2e, 0x2c,
    0x6c, 0x61, 0x74, 0x6e, 0x03, 0x03, 0x01
  ];

  const locale = Locale.fromString('bn');

  const provider = DataProvider.fromByteSlice(bnBlob);

  const format = DecimalFormatter.createWithGroupingStrategyAndProvider(provider, locale, DecimalGroupingStrategy.Auto);

  const decimal = Decimal.fromNumber(1234);
  decimal.multiplyPow10(-2);

  t.is(format.format(decimal), '১২.৩৪');
});
